<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function getIdKhoa(){
	var x =	document.getElementById("selectKhoa").value;
	return x;
	
	
}
</script>

<?php
include("config.php");
$idK = $_POST["selectKhoa"];
$idCN = $_GET["idchuyennganh"];
//idchuyennganh=<?= $_GET['idchuyennganh'];
?>

<form action="themHPvaoKhung.php?idchuyennganh=<?= $_GET['idchuyennganh'];?>" name="form1" method="post">

	Chọn Khoa Phụ Trách
	<?php
		$result = mysql_query("SELECT * from khoa");
	?>
	
	<select id="selectKhoa" name="selectKhoa" >
		
	<?php 
	while($row = mysql_fetch_array($result))
	{
	?>
	
	<option value="<?=$row['ID_KHOA']?>"  <?php if($idK==$row['ID_KHOA']) echo "selected='selected'"; ?>><?=$row['TENKHOA']?></option>
	
	<?php		
	}
	?>
	
	</select> 
	<input type="submit" name="Submit" value="Hiển thị học phần"/>
	</form>
<?php

if (isset($_POST["selectKhoa"]))
{
	echo $idCN;
	//$idCN = $_GET["idchuyennganh"];
	$str = "SELECT * FROM hocphan WHERE ID_KHOA =".$idK." 
			and ID_HOCPHAN not in (select ID_HOCPHAN from chuyennganhcohocphan where ID_CHUYENNGANH=".$idCN.")";
	echo $str;
	$result = mysql_query($str);
?>

<table width="300" border="1">
	<tr>
		<td>CHỌN</td>
		<td>MÃ HỌC PHẦN </td>
		<td>TÊN HỌC PHẦN</td>
	</tr>
	
	<?php
	while($row = mysql_fetch_array($result))
		{
			echo "<tr>";
			echo "<td><input name=\"chkbox\" type=\"checkbox\" value=\"\" /></td>";
			echo "<td>".$row['MAHOCPHAN']."</td>";
			echo "<td>".$row['TENHOCPHAN']."</td>";
			echo "</tr>";
		}//while
	}//if
	?>
</table>